#include "../include/Condition.h"
#include "../include/MutexLock.h"

namespace myNameSpace {
Condition::Condition(MutexLock &mutexLock): _mutexLock(mutexLock) {
    pthread_cond_init(&_cond, nullptr);
}

Condition::~Condition() {
    pthread_cond_destroy(&_cond);
}

void Condition::wait() {
    pthread_cond_wait(&_cond, _mutexLock.getMutexPtr());
}

void Condition::notify() {
    pthread_cond_signal(&_cond);
}

void Condition::notifyAll() {
    pthread_cond_broadcast(&_cond);
}
} // end of namespace myNameSpace
